#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <algorithm>
using namespace std;

int longestValidParentheses(string s) {
    int size = s.size(), result = 0;
    if (size < 2)return 0;
    vector<int> d(size + 1, 0);

    for (int i = 1; i < size; i++) {
        if (s[i] == ')') {
            if (s[i - 1] == '(') {
                d[i + 1] = d[i] = d[i - 1] + 2;
                result = max(result, d[i + 1]);
            } else {
                if (i - d[i] - 1 >= 0 && s[i - d[i] - 1] == '(') {
                    d[i + 1] = d[i - d[i]] = d[i] + 2 + d[i - d[i] - 1];
                    result = max(result, d[i + 1]);
                }
            }
        }
    }

        for (auto temp:d) {
            cout << temp;
            cout << ",";
        }
        cout << "\n";
        return result;

}



int main(){

    cout<<longestValidParentheses("(()()(()(()))()((()))((()(()())()(()))())))()(()()))())))))))()()()()))(((()())((()()(((())))()(()()(())((()))))))(()(()))(((()())()))(()))((((()(()()()())()()(()))(()()(())()((()()())))(())()())()(")<<endl;
    return 0;
}